package com.ljf.finance.infra.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ljf.common.exception.ServiceException;
import com.ljf.common.infra.repository.impl.BasisRepositoryImpl;
import com.ljf.common.utils.CollectionUtil;
import com.ljf.finance.domain.repository.FinanceDatVirtualAccountRepository;
import com.ljf.finance.dto.query.FinanceDatVirtualAccountQuery;
import com.ljf.finance.infra.mapper.FinanceDatVirtualAccountMapper;
import com.ljf.finance.model.FinanceDatVirtualAccount;
import com.ljf.finance.vo.FinanceDatVirtualAccountVO;
import org.springframework.stereotype.Component;

/**
 * 虚拟账户定义  数据访问接口实现
 *
 * @author LJF
 * @since 2024-02-08
 */
@Component
public class FinanceDatVirtualAccountRepositoryImpl extends BasisRepositoryImpl<FinanceDatVirtualAccountMapper, FinanceDatVirtualAccount, FinanceDatVirtualAccountQuery, FinanceDatVirtualAccountVO> implements FinanceDatVirtualAccountRepository {

    @Override
    protected QueryWrapper<FinanceDatVirtualAccount> fillWrapper(FinanceDatVirtualAccountQuery query, boolean sort) throws ServiceException {
        QueryWrapper<FinanceDatVirtualAccount> wrapper = super.fillWrapper(query, false);
        if (CollectionUtil.isNotEmpty(query.getCodeList())) {
            wrapper.in(FinanceDatVirtualAccount.COL_CODE, query.getCodeList());
        }
        if (CollectionUtil.isNotEmpty(query.getShortNameList())) {
            wrapper.in(FinanceDatVirtualAccount.COL_SHORT_NAME, query.getShortNameList());
        }
        wrapper.orderByAsc(FinanceDatVirtualAccount.COL_SORT);
        return wrapper;
    }

}
